package com.xpxrule.controller.manage;

import com.xpxrule.dataobject.biz.model.ReturnResponse;
import com.xpxrule.dataobject.req.RuleQueryReq;
import com.xpxrule.dataobject.vo.BusinessModelVo;
import com.xpxrule.dataobject.vo.OptionVo;
import com.xpxrule.dataobject.vo.RuleDisplayVo;
import com.xpxrule.dataobject.vo.RuleVo;
import com.xpxrule.service.RuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @version 1.0
 * @Author xiangpengxiang
 * @Date 2024/12/9 15:35
 * @注释
 */
@RestController
@RequestMapping("/rule")
public class RuleController {
    @Autowired
    private RuleService ruleService;

    /**
     * 新增规则
     * @param vo
     * @return
     */
    @PostMapping("/insert")
    public ReturnResponse<Integer> insert(@RequestBody RuleVo vo) {
        return ruleService.insert(vo);
    }

    /**
     * 根据id删除规则
     * @param id
     * @return
     */
    @GetMapping("/delete/{id}")
    public ReturnResponse<Integer> delete(@PathVariable("id") Long id) {
        return ruleService.delete(id);
    }

    /**
     * 根据id更新业务模型
     * @param vo
     * @return
     */
    @PostMapping("/update")
    public ReturnResponse<Integer> update(@RequestBody RuleVo vo) {
        return ruleService.update(vo);
    }

    /**
     * 根据查询条件查询规则列表
     * @param req
     * @return
     */
    @PostMapping("/select/byQuery")
    public ReturnResponse<List<RuleVo>> selectList(@RequestBody RuleQueryReq req) {
        return ruleService.selectList(req);
    }

    /**
     * 根据查询条件查询规则列表
     * @param req
     * @return
     */
    @PostMapping("/select/ruleDisplay/byQuery")
    public ReturnResponse<List<RuleDisplayVo>> selectRuleDisplayList(@RequestBody RuleQueryReq req) {
        return ruleService.selectRuleDisplayList(req);
    }

    /**
     * 获取所有操作符
     * @return
     */
    @GetMapping("/get/all/operator")
    public ReturnResponse<List<OptionVo>> getAllOperator() {
        return ruleService.getAllOperator();
    }
}
